#ifndef _REGIONMANAGER_
#define	_REGIONMANAGER_

#include "ObjectManager.hpp"
#include "Entity.hpp"
#include "Region.hpp"
#include "Content/Map.hpp"
#include "Scripting/Scripting.hpp"

/**
 * Manager of a set of regions.
 * Region implementation that is registerred in the region must be
 * registerred by name "Region" in lua.
 * @see Region
 */
class RegionManager: public ObjectManager{
protected:
    
public:

    /** The map that regions in this RegionManager exist in. */
    Map* map;
    /** Array of regions in manager.*/
    Region** regions;

    RegionManager();

    /**
     * Update all Regions in this RegionManager.
     * @param frameTime Time of update.
     */
    virtual void update(unsigned int frameTime) = 0;
    
    virtual void onentry(Region* region, Scriptable* entity);
    virtual void onexit(Region* region, Scriptable* entity);

    virtual Region* findRegion(const char* name);

    /**
     * Create a new region and add it to this RegionManager.
     * @return Pointer to created Region or 0 on failure.
     */
    virtual Region* createRegion(const char* name) = 0;

    /**
     * Remove given region from this RegionManager.
     * @return true if found, false if not.
     */
    virtual bool destroyRegion(Region* region) = 0;
};

#endif